<script>
  init({
    title: 'i18n Enhance',
    desc: 'Use Plugin: bootstrap-table-i18n-enhance.',
    links: ['bootstrap-table.min.css'],
    scripts: [
      'bootstrap-table.min.js',
      'extensions/i18n-enhance/bootstrap-table-i18n-enhance.min.js'
    ]
  })
</script>

<div id="toolbar">
  <label>Language:</label>
  <div class="btn-group" role="group" style="margin-bottom: 4px">
    <button id="tw_Btn" type="button" class="btn btn-secondary btn-sm active">zh_TW</button>
    <button id="us_Btn" type="button" class="btn btn-secondary btn-sm">en_US</button>
  </div>
</div>

<table
  id="table"
  data-url="json/data1.json"
  data-pagination="true"
  data-toolbar="#toolbar">
  <thead>
    <tr>
      <th data-field="id">代碼</th>
      <th data-field="name">項目名稱</th>
      <th data-field="price">項目金額</th>
    </tr>
  </thead>
</table>

<script>
  function mounted() {
    var $table = $('#table')
    var $buttons = $('button')

    $table.bootstrapTable()

    $('#tw_Btn').click(function () {
      $buttons.removeClass('active')
      $(this).addClass('active')

      $table.bootstrapTable('changeLocale', 'zh-TW')
      $table.bootstrapTable('changeTitle', {
        id: '代碼',
        name: '項目名稱',
        price: '項目金額'
      })
    })

    $('#us_Btn').click(function () {
      $buttons.removeClass('active')
      $(this).addClass('active')

      $table.bootstrapTable('changeLocale', 'en_US')
      $table.bootstrapTable('changeTitle', {
        id: 'ID',
        name: 'Item Name',
        price: 'Item Price'
      })
    })
  }
</script>
